Ext.define('Inbox.view.inbox.FolderPost', {
	extend : 'Ext.panel.Panel',
	alias : 'widget.folderPost',
	autoScroll : true,
	cls : 'preview',
	border : true,

	initComponent : function() {
		Ext.apply(this, {
			tpl: Ext.create('Ext.XTemplate', '<div class="post-data">',
                    '<h3 class="post-title">{title}</h3>',
                    '<h4 class="post-author">by {author:this.defaultValue}',
                    '<span class="post-date">{pubDate:this.formatDate}</span>',
                '</h4></div>',
                '<div class="post-body">{content:this.getBody}</div>',
                {
                    getBody: function(value, all){
                        return Ext.util.Format.stripScripts(value);
                    },

                    defaultValue: function(v){
                        return v ? v : 'Unknown';
                    },

                    formatDate: function(value){
                        if (!value) {
                            return '';
                        }
                        return Ext.Date.format(value, 'M j, Y, g:i a');
                    }
                })
		});
		this.callParent(arguments);
	},

	setActive : function(rec) {
		var me = this;
		me.active = rec;
		me.update(rec.data);
	},
	
	openTab: function(){
		this.fireEvent('opentab', this, this.active);
	}
});